
<template>
  <div>
    <!-- 退改规则 -->
    <VolBox class="RefundrulesBox" :model.sync="model" :title="title == 0 ? '退改规则--新增' : '退改规则--编辑'"
      :width="1050" :height="500">
      <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px">
        <el-form-item prop="refundName" label="规则名称">
          <el-input class="wid200" v-model="ruleForm.refundName" />
        </el-form-item>
        <el-form-item label="退票规则">
          <el-button-group>
            <el-button :class="gz_list_tp_index == ii ? 'hover' : ''" v-for="(i, ii) in gz_list_tp"
              :key="ii" @click="gz_list_tp_cl(i.id)" round size="mini">{{ i.name }}</el-button>
          </el-button-group>
          <div class="gz_list_tp_cont">
            <div class="gz_1_cont_1">
              {{ gz_1_cont_text.title }}
            </div>
            <div v-if="gz_list_tp_index != 0">
              <el-radio @change="radioChaneg" v-for="(item,index) in gz_1_cont_text.radio"
                :key="index" v-model="isApprove" :label="item.key">
                {{ item.name }}</el-radio>
                <div v-if=" isApprove == 0 && 'radio' in gz_1_cont_text" style="margin: 10px 0;">
                  <el-input class="timeWid180" v-model="voluntarilyRefundHour" />分钟
                </div>
                <div class="gz_1_cont_3" >{{ gz_1_cont_text.zs}}</div>
            </div>
          </div>
        </el-form-item>
        <div v-show="gz_list_tp_index != 0">
          <el-form-item label="可退时间" v-if="gz_list_tp_index == 1">
            <el-button-group>
              <el-button :class="gz_list_sj_index == ii ? 'hover' : ''"
                v-for="(i, ii) in gz_list_sj" :key="ii" @click="gz_list_sj_cl(i.id)" round
                size="mini">{{ i.name }}</el-button>
            </el-button-group>
            <div>
              <div>
                {{ gz_list_kssjText.o }}
              </div>
              <div>
                {{ gz_list_kssjText.t
                }}
                <el-input-number controls-position="right" v-model="refundDay" size="mini"
                  :min="0" />{{ gz_list_kssjText.y }}
                <el-time-picker size="mini" class="timeWid" format="HH:mm" value-format="HH:mm"
                  v-model="refundHours">
                </el-time-picker>
                {{ gz_list_kssjText.u }}
              </div>
            </div>
          </el-form-item>
          <!-- <el-form-item label="可退数量">
            <el-button-group>
              <el-button
                :class="gz_list_num_index == ii ? 'hover' : ''"
                v-for="(i, ii) in gz_list_num"
                :key="ii"
                @click="gz_list_num_cl(i.id)"
                round
                size="mini"
                >{{ i.name }}</el-button
              >
            </el-button-group>
            <div class="gz_maTop10" v-if="gz_list_num_index == 0">
              最多不超过初始订单购买数量
            </div>
            <div class="gz_maTop10" v-else>
              <div>
                初始订单的
                <el-input
                  class="inputWid"
                  v-model="InitialOrder"
                  size="mini"
                />% 加票不受提前预订属性限制
              </div>
              <div class="gz_maTop10">
                <el-checkbox
                  v-model="checkboxLessthan"
                  @change="checkboxCha"
                />最少不低于
                <el-input
                  class="inputWid"
                  v-model="Lessthan"
                  size="mini"
                  :disabled="!checkboxLessthan"
                ></el-input>
                张 选中时限制每次下单最少不低于该数量
              </div>
            </div>
          </el-form-item> -->
          <el-form-item label="退票手续费">
            <el-button-group>
              <el-button :class="gz_list_tpsxf_index == ii ? 'hover' : ''"
                v-for="(i, ii) in gz_list_tpsxf" :key="ii" @click="gz_list_tpsxf_cl(i.id)" round
                size="mini">{{ i.name }}</el-button>
            </el-button-group>
            <div v-show="gz_list_sxf_status">
              0元为无需手续费，需要手续费支持配置固定金额以及阶梯金额的方式来收取
            </div>
          </el-form-item>
          <el-form-item label="手续费方式" v-show="gz_list_sxf_status">
            <el-button-group>
              <el-button :class="gz_list_sxffs_index == ii ? 'hover' : ''"
                v-for="(i, ii) in gz_list_sxffs" :key="ii" @click="gz_list_sxffs_cl(i.id)" round
                size="mini">{{ i.name }}</el-button>
            </el-button-group>
            <div v-if="gz_list_sxffs_index == 0">
              <div>配置每张票即手续费=退票数*单张金额，每次发起时收取；</div>
              <div>
                每张票
                <el-input class="timeWid" v-model="fixedamount.amount" size="mini"
                  @blur="amountBlur" />
                <el-select class="timeWid" v-model="fixedamount.unit" size="mini"
                  @change="amountBlur">
                  <el-option label="元" value="0"></el-option>
                  <el-option label="%" value="1"></el-option>
                </el-select>
              </div>
            </div>
            <div class="sxf" v-else>
              <div>
                不同区间收取游客不同金额的手续费（位于区间内收取，未在区间则不收取，包含配置的X点），检票截止日期即有效期结束日期
              </div>
              <div>
                <div>
                  购票后至截止游玩结束日期
                  <el-select class="inputWid60" v-model="stepamount.dayaround" size="mini"
                    @change="daySetAround">
                    <el-option label="前" value="front"></el-option>
                    <el-option label="后" value="after"></el-option>
                  </el-select>
                  <el-input-number class="inputWid90" controls-position="right"
                    v-model="stepamount.day" size="mini" :min="0" />
                  <el-time-picker class="timeWid" format="HH:mm" value-format="HH:mm"
                    v-model="stepamount.time" size="mini" @change="timeChange">
                  </el-time-picker>
                  天， 每张票
                  <el-input class="inputWid90" v-model="fixedamount.amount" size="mini"
                    @blur="amountBlur" />
                  <el-select class="inputWid60" v-model="fixedamount.unit" size="mini"
                    @change="amountBlur">
                    <el-option label="元" value="0"></el-option>
                    <el-option label="%" value="1"></el-option>
                  </el-select>
                  <i type="primary" class="el-icon-circle-plus-outline" @click="circlePlus"></i>
                </div>
              </div>
              <div>
                <div v-for="(i, ii) in formList" :key="ii" class="gz_maTop10">
                  <div class="disInBo">
                    {{i.dayTimeText}}
                    <el-select class="inputWid60" v-model="i.dayaround" size="mini"
                      @change="selectForCha(i, ii)">
                      <el-option label="前" value="front"></el-option>
                      <el-option label="后" value="after"></el-option>
                    </el-select>
                    <el-input-number class="inputWid90" controls-position="right" v-model="i.day"
                      size="mini" :min="0" @change="upDayTimTex2(i, ii)" />
                    天的
                    <!-- <el-time-picker class="timeWid" format="HH:mm" value-format="HH:mm"
                      v-model="i.time" size="mini" @change="upDayTimTex(i, ii)">
                    </el-time-picker> -->
                    <el-time-picker class="timeWid" format="HH:mm" value-format="HH:mm"
                      v-model="i.time" size="mini">
                    </el-time-picker>

                  </div>
                  天， 每张票
                  <el-input class="inputWid90" v-model="i.amount" size="mini" @blur="amountBlurs" />
                  <el-select class="inputWid60" v-model="i.unit" size="mini" @change="amountBlurs">
                    <el-option label="元" value="0"></el-option>
                    <el-option label="%" value="1"></el-option>
                  </el-select>
                  <i type="primary" class="el-icon-remove-outline" @click="circleRemove(ii)"></i>
                </div>
              </div>
            </div>
          </el-form-item>
          <!-- <el-form-item label="过期操作">
            <el-button-group>
              <el-button :class="gz_list_gq_index == ii ? 'hover' : ''"
                v-for="(i, ii) in gz_list_gq" :key="ii" @click="gz_list_gq_cl(i.id)" round
                size="mini">{{ i.name }}</el-button>
            </el-button-group>
            <div class="gz_maTop10" v-if="gz_list_gq_index == 1">
              <el-input class="inputWid90" v-model="autoEnd1" size="mini" />天后自动核销
            </div>
            <div class="gz_maTop10" v-if="gz_list_gq_index == 2">
              <el-input class="inputWid90" v-model="autoEnd2" size="mini" />天后自动取消，手续费
              <el-input class="inputWid90" v-model="serviceShargeDiscount" size="mini" />%
              <div>
                <el-checkbox v-model="isAutoEnd">
                  已取票/部分取票订单不自动取消</el-checkbox>
              </div>
            </div>
          </el-form-item> -->
        </div>
      </el-form>
      <div slot="footer">
        <Button type="error" icon="md-checkmark" @click="submit('ruleForm')" v-loading="loading">
          保存</Button>
        <Button type="success" icon="md-refresh" @click="resetting('ruleForm')"> 重置</Button>
        <Button type="info" icon="md-close" @click="model = false">关闭</Button>
      </div>
    </VolBox>
  </div>
</template>

<script>
import VolBox from "@/components/basic/VolBox.vue";
export default {
  components: {
    VolBox,
  },
  data() {
    return {
      model: false,
      title: "",
      ruleForm: {
        refundName: "",
      },
      rules: {
        refundName: [
          { required: true, message: "请输入活动名称", trigger: "blur" },
        ],
      },
      GZID: "",
      gz_list_tp: [
        {
          id: 0,
          name: "不可退",
        },
        {
          id: 1,
          name: "有条件退",
        },
        {
          id: 2,
          name: "随时退",
        },
      ],
      gz_list_tp_cont: [
        {
          title: "门票购买后不可退款",
          check: "",
          zs: "",
        },
        {
          title: "未消费门票允许发起退票，有时间节点、手续费等限制",
          radio: [
            {
              name: "退票需人工审核",
              key: 1,
            },
            {
              name: "自动退",
              key: 0,
            },
          ],
          zs: "对接第三方票务系统时，实际审核权在第三方。美团退票申请后3个工作日未收到回复将自动退款。人工审核无法支持美团同笔订单多次退票审核。",
        },
        {
          title: "未消费（包含过期）门票随时可退，支持配置收取手续费",
          radio: [
            {
              name: "退票需人工审核",
              key: 1,
            },
            {
              name: "自动退",
              key: 0,
            },
          ],

          zs: "对接第三方票务系统时，实际审核权在第三方。美团退票申请后3个工作日未收到回复将自动退款。人工审核无法支持美团同笔订单多次退票审核。",
        },
      ],
      gz_1_cont_text: "",
      isApprove: 0,
      voluntarilyRefundHour: null,
      gz_list_sj: [
        {
          id: 0,
          name: "有效期前X天内可退",
        },
        {
          id: 1,
          name: "有效期后X天内可退",
        },
      ],
      gz_list_kssj: [
        {
          o: "未消费门票在有效期结束日期前X天的X点(含)前可退 (原有效期内可退和游玩前X天可退合并成新选项)",
          t: "在检票截止日期（有效期结束日期）前",
          y: "天的",
          u: "前可退",
        },
        {
          o: "未消费门票在有效期结束日期后X天的X点(含)前可退",
          t: "在检票截止日期（有效期结束日期）后",
          y: "天的",
          u: "前可退",
        },
      ],
      gz_list_kssjText: {},
      refundDay: 1,
      gz_list_sj_status: false,
      InitialOrder: 0,
      Lessthan: 0,
      checkboxLessthan: false,
      gz_list_num: [
        {
          id: 0,
          name: "不限",
        },
        {
          id: 1,
          name: "限制",
        },
      ],
      gz_list_num_status: true,
      gz_list_tpsxf: [
        {
          id: 0,
          name: "0元",
        },
        {
          id: 1,
          name: "需要手续费",
        },
      ],
      gz_list_sxf_status: false,
      gz_list_sxffs: [
        {
          id: 0,
          name: "固定金额",
        },
        {
          id: 1,
          name: "阶梯金额",
        },
      ],
      fixedamount: {
        amount: "0.00",
        unit: "0",
      },
      gz_list_gq: [
        {
          id: 0,
          name: "不处理",
        },
        {
          id: 1,
          name: "自动核销",
        },
        {
          id: 2,
          name: "自动取消",
        },
      ],
      gz_list_sj_index: 0,
      gz_list_sj_index: 0,
      gz_list_num_index: 0,
      gz_list_tpsxf_index: 0,
      gz_list_sxffs_index: 0,
      gz_list_gq_index: 0,
      gz_list_sxffsf_status: false,
      stepamount: {
        dayaround: "front",
        day: 0,
        time: "23:59",
      },
      formList: [],
      autoEnd1: 0,
      autoEnd2: 0,
      autoEnd3: 0,
      serviceShargeDiscount: "",
      isAutoEnd: "",
      loading: false,
      refundHours: "23:59",
      gz_list_tp_index: 0
    };
  },
  watch: {
    // formList(v, n) {
    //   if (v.length > 0) {
    //     for (let i = 0; i < v; i++) {
    //       console.log(v[i]);
    //     }
    //   }
    // },
    isApprove(v, n) {
      this.voluntarilyRefundHour = null;
    },
    "stepamount.day"(newVal, oldVal) {
      let num = this.stepamount.day + 1;
      this.formList.map((_, i) => {
        num = num - 1;
        // this.$set(this.formList[i], 'jzDay', num) // this.$set(this.formList[i], 'day', num - 1)
        this.$set(this.formList[i], "jzDay", num < 0 ? 0 : num);
        this.$set(this.formList[i], "day", num - 1 < 0 ? 0 : num - 1);
        let qh = this.stepamount.dayaround == "front" ? "前" : "后";
        _.dayTimeText =
          "截止游玩结束日期" +
          qh +
          _.jzDay +
          "天的" +
          (_.time == null ? "" : _.time);
      });
    },
  },
  created() {
    this.gz_list_tp_cl(0);
    this.gz_list_sj_cl(0);
  },
  methods: {
    // 单选框
    radioChaneg(val) {
      console.log(val, this.isApprove);
    },
    upDayTimTex2(v, inx) {
      this.formList.map((_, i) => {
        if (inx < i) {
          this.$set(
            this.formList[i],
            "jzDay",
            this.formList[i - 1].day < 0 ? 0 : this.formList[i - 1].day
          );
          let qh = this.stepamount.dayaround == "front" ? "前" : "后";
          this.$set(
            this.formList[i],
            "day",
            this.formList[i - 1].day - 1 < 0 ? 0 : this.formList[i - 1].day - 1
          );
          this.$set(
            this.formList[i],
            "dayTimeText",
            "截止游玩结束日期" +
              qh +
              _.jzDay +
              "天的" +
              (_.time == null ? "" : _.time)
          );
        } else if (inx + 1 == i) {
          this.$set(this.formList[i], "jzDay", v.day < 0 ? 0 : v.day);
          let qh = this.stepamount.dayaround == "front" ? "前" : "后";
          this.$set(this.formList[i], "day", v.day - 1 < 0 ? 0 : v.day - 1);
          this.$set(
            this.formList[i],
            "dayTimeText",
            "截止游玩结束日期" +
              qh +
              _.jzDay +
              "天的" +
              (_.time == null ? "" : _.time)
          );
        }
      });
    },
    // 退票规则
    gz_list_tp_cl(v) {
      console.log(v);
      this.gz_list_tp_index = v;
      this.gz_1_cont_text = this.gz_list_tp_cont[v];
    },
    // 可退时间
    gz_list_sj_cl(v) {
      this.gz_list_sj_index = v;
      this.gz_list_kssjText = this.gz_list_kssj[v];
      if (v == 0) {
        this.gz_list_sj_status = false;
      } else {
        this.gz_list_sj_status = true;
      }
    },
    // 可退数量
    gz_list_num_cl(v) {
      this.gz_list_num_index = v;
    },
    checkboxCha() {
      this.Lessthan = this.checkboxLessthan ? this.Lessthan : 0;
    },
    // 退票手续费
    gz_list_tpsxf_cl(v) {
      this.gz_list_tpsxf_index = v;
      if (v == 0) {
        this.gz_list_sxf_status = false;
      } else {
        this.gz_list_sxf_status = true;
      }
    },
    // 手续费方式
    gz_list_sxffs_cl(v) {
      this.gz_list_sxffs_index = v;
      if (v == 0) {
        this.gz_list_sxffsf_status = false;
      } else {
        this.gz_list_sxffsf_status = true;
      }
    },
    // 过期操作
    gz_list_gq_cl(v) {
      this.gz_list_gq_index = v;
    },
    amountBlur() {
      if (this.fixedamount.unit == 0) {
        this.fixedamount.amount = Number(this.fixedamount.amount).toFixed(2);
      } else {
        this.fixedamount.amount = Number(this.fixedamount.amount).toFixed(0);
      }
    },
    amountBlurs() {
      this.formList.forEach((i) => {
        if (i.unit == 0) {
          i.amount = Number(i.amount).toFixed(2);
        } else {
          i.amount = Number(i.amount).toFixed(0);
        }
      });
    },
    circlePlus() {
      // 前 10天，+则10,9,8,7...
      // 后 10天，+ 11,12,13...
      // 后，则全后
      // 前，则全前
      // 前一前则后一后
      let obj = {
        dayaround: "front",
        day: this.stepamount.day,
        jzDay: this.stepamount.day,
        time: "23:59",
        amount: "0.00",
        unit: "0",
      };
      if (this.formList.length < 9) {
        if (this.formList.length == 0) {
          if (this.stepamount.dayaround == "after") {
            obj.day = this.stepamount.day + 1;
            obj.dayaround = "after";
            obj.disabled = true;
          } else {
            if (this.stepamount.day == 0) {
              obj.day = 0;
            } else {
              obj.jzDay = obj.day;
              obj.day = obj.jzDay - 1;
            }
            obj.dayaround = "front";
            obj.disabled = false;
          }
          let qh = this.stepamount.dayaround == "front" ? "前" : "后";
          obj.dayTimeText =
            "截止游玩结束日期" +
            qh +
            obj.jzDay +
            "天的" +
            (obj.time == null ? "" : obj.time);
          this.formList.push(obj);
        } else {
          this.formList[0].jzDay = this.stepamount.day;
          this.formList[0].day = this.stepamount.day + 1;
          this.formList.push(obj);
          if (this.stepamount.dayaround == "after") {
            this.formList[0].dayTimeText =
              "截止游玩结束日期后" +
              this.formList[0].jzDay +
              "天的" +
              (this.formList[0].time == null ? "" : this.formList[0].time);
            this.formList.forEach((i, ii, arr) => {
              i.dayaround = "after";
              i.disabled = true;
              if (ii > 0) {
                arr[ii].jzDay = arr[ii - 1].day;
                arr[ii].day = arr[ii].jzDay + 1;
                arr[ii].dayTimeText =
                  "截止游玩结束日期后" +
                  arr[ii].jzDay +
                  "天的" +
                  (i.time == null ? "" : i.time);
              }
            });
          } else {
            this.formList[0].jzDay = this.stepamount.day;
            this.formList[0].day = this.stepamount.day - 1;
            this.formList[0].dayTimeText =
              "截止游玩结束日期前" +
              this.formList[0].jzDay +
              "天的" +
              (this.formList[0].time == null ? "" : this.formList[0].time);
            this.formList.forEach((i, ii, arr) => {
              i.dayaround = "front";
              i.disabled = false;
              if (ii > 0) {
                arr[ii].jzDay = arr[ii - 1].day;
                arr[ii].day = arr[ii].jzDay - 1;
                if (arr[ii - 1].day == 0) {
                  arr[ii].jzDay = 0;
                  arr[ii].day = 0;
                }
                arr[ii].dayTimeText =
                  "截止游玩结束日期前" +
                  arr[ii].jzDay +
                  "天的" +
                  (i.time == null ? "" : i.time);
              }
            });
          }
        }
      } else {
        this.$message({
          message: "手续费方式：阶梯金额最多配置10条规则",
          type: "warning",
        });
      }
    },
    circleRemove(v) {
      this.formList.forEach((i, ii, arr) => {
        if (v == ii) {
          arr.splice(ii, 1);
        }
      });
    },
    timeChange() {
      let qh = this.stepamount.dayaround == "front" ? "前" : "后";
      this.formList[0].dayTimeText =
        "截止游玩结束日期" +
        qh +
        this.formList[0].jzDay +
        "天的" +
        (this.stepamount.time == null ? "" : this.stepamount.time);
    },
    // 手续费方式 -- 购票后至检票截止日期
    daySetAround() {
      if (this.stepamount.dayaround == "after") {
        if (this.stepamount.day == 0) {
          this.stepamount.day = 1;
        }
        if (this.formList.length > 0) {
          this.formList[0].jzDay = this.stepamount.day;
          this.formList[0].day = this.stepamount.day + 1;
          this.formList[0].dayTimeText =
            "截止游玩结束日期后" +
            this.formList[0].jzDay +
            "天的" +
            (this.formList[0].time == null ? "" : this.formList[0].time);

          this.formList.forEach((i, ii, arr) => {
            i.dayaround = "after";
            i.disabled = true;
            if (ii > 0) {
              arr[ii].jzDay = arr[ii - 1].day;
              arr[ii].day = arr[ii].jzDay + 1;
              arr[ii].dayTimeText =
                "截止游玩结束日期后" +
                arr[ii].jzDay +
                "天的" +
                (i.time == null ? "" : i.time);
            }
          });
        }
      } else {
        this.formList[0].disabled = false;
        this.formList[0].dayaround = "after";
        this.formList[0].dayTimeText =
          "截止游玩结束日期前" +
          this.formList[0].jzDay +
          "天的" +
          (this.formList[0].time == null ? "" : this.formList[0].time);
      }
    },
    selectForCha(v, inx) {
      this.formList[inx + 1].dayaround = "after";
      if (v.dayaround == "front") {
        this.formList[inx + 1].disabled = false;
        this.formList[inx + 1].dayTimeText =
          "截止游玩结束日期前" +
          this.formList[inx + 1].jzDay +
          "天的" +
          (this.formList[inx].time == null ? "" : this.formList[inx].time);
      } else {
        this.formList[inx + 1].disabled = true;
        this.formList[inx + 1].dayTimeText =
          "截止游玩结束日期后" +
          this.formList[inx + 1].jzDay +
          "天的" +
          (this.formList[inx].time == null ? "" : this.formList[inx].time);
      }
    },
    upDayTimTex(v, inx) {
      let qh = v.dayaround == "front" ? "前" : "后";
      this.formList[inx + 1].jzDay = v.day;
      this.formList[inx + 1].day = this.formList[inx + 1].jzDay + 1;
      this.formList[inx + 1].dayTimeText =
        "截止游玩结束日期" +
        qh +
        this.formList[inx + 1].jzDay +
        "天的" +
        (v.time == null ? "" : v.time);
    },
    resetting() {
      // console.log("重置")
      this.ruleForm.refundName = "";
      this.gz_list_tp_cl(0);
      this.gz_list_sj_cl(0);
      this.gz_list_tpsxf(0);
    },
    submit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          let voluntarilyRefundHour = ''
          let status = false
          if (this.voluntarilyRefundHour) {
            if (parseInt(this.voluntarilyRefundHour) < 5) {
              this.$message({
                  message: '分钟不能小于5分钟',
                  type: "error",
                });
                status = false
            } else {
              status = true
              voluntarilyRefundHour = parseInt(this.voluntarilyRefundHour)
            }
          } else {
            status = true
            voluntarilyRefundHour = null
          }
          let params = {
            refundName: this.ruleForm.refundName,
            basic: this.gz_list_tp_index,
            isApprove: this.isApprove ? 1 : 0,
            beforeDate: "",
            afterDate: "",
            refundHours: this.refundHours,
            refundCount: "",
            isServiceCharge: this.gz_list_tpsxf_index,
            fixedamount: "",
            stepamount: "",
            isExpirationRefundable: this.gz_list_gq_index,
            autoEnd: this.autoEnd,
            isAutoEnd: this.isAutoEnd,
            serviceShargeDiscount: this.serviceShargeDiscount,
            // 自动退时间
            voluntarilyRefundHour: voluntarilyRefundHour
          }
          // 可退时间
          if (this.gz_list_sj_index == 0) {
            params.beforeDate = this.refundDay;
            params.afterDate = "";
          } else {
            params.beforeDate = "";
            params.afterDate = this.refundDay;
          }
          // 可退数量
          if (this.gz_list_num_index == 0) {
            params.refundCount = "";
          } else {
            let o = {
              InitialOrder: this.InitialOrder,
              Lessthan: this.checkboxLessthan ? this.Lessthan : "",
            };
            params.refundCount = JSON.stringify(o);
          }
          // 手续费方式
          if (this.gz_list_sxffs_index == 0) {
            let o = {
              amount: this.fixedamount.amount,
              unit: this.fixedamount.unit,
            };
            params.fixedamount = JSON.stringify(o);
            params.stepamount = "";
          } else {
            let obj = {
              dayaround: this.stepamount.dayaround,
              day: this.stepamount.day,
              time: this.stepamount.time,
              amount: this.fixedamount.amount,
              unit: this.fixedamount.unit,
              after: 0,
              sort: 0,
            };
            let c = this.formList.map((i, ii) => {
              return {
                dayaround: i.dayaround,
                day: i.day,
                time: i.time,
                amount: i.amount,
                unit: i.unit,
                sort: ii + 1,
              };
            });
            params.fixedamount = "";
            params.stepamount = JSON.stringify([obj, ...c]);
          }
          // 过期操作
          // if (this.gz_list_gq_index == 0) {
          //   params.autoEnd = 0;
          // } else if (this.gz_list_gq_index == 1) {
          //   params.autoEnd = this.autoEnd1;
          // } else if (this.gz_list_gq_index == 2) {
          //   params.autoEnd = this.autoEnd2;
          // }
          // if (this.gz_list_gq_index != 2) {
          //   params.isAutoEnd = '';
          //   params.serviceShargeDiscount = '';
          // }
          
          if (status) {
            this.loading = true;
            if (this.title === 0) {
              this.http
                .post("/api/Refundrules/RefundAdd", {
                  mainData: params,
                  detailData: [],
                  delKeys: null,
                })
                .then((res) => {
                  this.loading = false;
                  if (res.status) {
                    this.model = false;
                    this.$store.getters.data().viewPageTest.refresh();
                  } else {
                    this.model = true;
                    this.$message({
                      message: res.message,
                      type: "error",
                    });
                  }
                });
            } else {
              params.id = this.GZID;
              this.http
                .post("/api/Refundrules/RefundUpdate", {
                  mainData: params,
                  detailData: null,
                  delKeys: null,
                })
                .then((res) => {
                  this.loading = false;
                  if (res.status) {
                    this.model = false;
                    this.$store.getters.data().viewPageTest.refresh();
                  } else {
                    this.model = true;
                    this.$message({
                      message: res.message,
                      type: "error",
                    });
                  }
                });
            }
          }
          
        }
      });
    },
  },
};
</script>
<style lang="scss">
.RefundrulesBox {
  .el-form {
    padding-bottom: 20px;
  }
  .el-form-item__label {
    line-height: 25px !important;
  }
  .el-form-item__content {
    line-height: 25px !important;
  }
  .inputWid {
    .el-input__inner {
      padding: 3px !important;
    }
  }
}
</style>
<style lang="scss" scoped>
.wid200{
  width: 200px;
}
.hover {
  color: #82aaf1;
  border-color: rgb(218, 230, 251);
  background-color: rgb(243, 247, 254);
}
.gz_list_tp_cont {
  .gz_1_cont_3 {
    color: red;
  }
}
.inputWid {
  width: 50px;
}
.timeWid {
  width: 130px;
}
.inputWid60 {
  width: 60px;
}
.inputWid70 {
  width: 70px;
}
.inputWid90 {
  width: 90px;
}
.timeWid180 {
  width: 200px;
}
.el-icon-circle-plus-outline {
  font-size: 24px;
}
.el-icon-remove-outline {
  font-size: 24px;
}
.gz_maTop10 {
  margin-top: 10px;
}
.disInBo {
  display: inline-block;
}
</style>